package com.alogic.cron;

public class Main {
    public static void main(String[] args){
        CronMatcher matcher = CronMatcherFactory.getMatcher("(interval)interval=2000");
        long lastDate = 0;
        long cnt = 0;
        while (cnt++ < 10){
            long now = System.currentTimeMillis();
            if (matcher.match(lastDate,now)){
                System.out.println(now + "->interval");
                lastDate = now;
            }
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        matcher = CronMatcherFactory.getMatcher("(once)");
        lastDate = 0;
        cnt = 0;
        while (cnt++ < 10){
            long now = System.currentTimeMillis();
            if (matcher.match(lastDate,now)){
                System.out.println(now + "->once");
                lastDate = now;
            }
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        matcher = CronMatcherFactory.getMatcher("(counter)interval=2000;count=2");
        lastDate = 0;
        cnt = 0;
        while (cnt++ < 10){
            long now = System.currentTimeMillis();
            if (matcher.match(lastDate,now)){
                System.out.println(now + "->counter");
                lastDate = now;
            }
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        matcher = CronMatcherFactory.getMatcher("(cron)* * * * *");
        lastDate = 0;
        cnt = 0;
        while (cnt++ < 36000){
            long now = System.currentTimeMillis();
            if (matcher.match(lastDate,now)){
                System.out.println(now + "->cron");
                lastDate = now;
            }
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
